﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CycleTimeReport.CApCTRTimerSupportPriority
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.CycleTimeReport;

public class CApCTRTimerSupportPriority : CApCTRTimer
{
  public CApCTRTimerSupportPriority(
    string name,
    int originalEventIndex,
    double startTime,
    double endTime,
    double duration,
    string description,
    object eventObject1,
    object eventObject2,
    object eventObject3,
    TxRobot robot,
    int priority,
    bool timerIsStoppedInTheMiddle = false)
    : base(name, originalEventIndex, startTime, endTime, duration, description, eventObject1, eventObject2, eventObject3, robot, timerIsStoppedInTheMiddle)
  {
    this.InactiveDuration = this.EndTime - this.StartTime - this.ActiveDuration;
    this.Priority = priority;
  }

  public CApCTRTimerSupportPriority(
    string name,
    int originalEventIndex,
    double startTime,
    double duration,
    TxRobot robot,
    int priority)
    : base(name, originalEventIndex, startTime, startTime + duration, duration, (string) null, (object) duration.ToString(), (object) null, (object) null, robot)
  {
    this.InactiveDuration = this.EndTime - this.StartTime - this.ActiveDuration;
    this.Priority = priority;
  }

  internal double InactiveDuration { get; set; }

  internal int Priority { get; set; }

  public override string ToString()
  {
    string str = "StartTime " + CApCTRUtilities.DoubleToString(this.StartTime, "f3", true) + ";" + "EndTime " + CApCTRUtilities.DoubleToString(this.EndTime, "f3", true) + ";" + "Name " + this.Name + ";" + "ActiveDuration " + CApCTRUtilities.DoubleToString(this.ActiveDuration, "f3", true) + ";" + "InactiveDuration " + CApCTRUtilities.DoubleToString(this.InactiveDuration, "f3", true) + ";";
    if (this.Object1 != null && this.Object1 is ITxObject && (this.Object1 as ITxObject).IsValid())
      str = $"{str}  {(this.Object1 as ITxObject).Name}";
    if (this.Object2 != null && this.Object2 is ITxObject && (this.Object2 as ITxObject).IsValid())
      str = $"{str}  {(this.Object2 as ITxObject).Name}";
    if (this.Object3 != null && this.Object3 is ITxObject && (this.Object3 as ITxObject).IsValid())
      str = $"{str}  {(this.Object3 as ITxObject).Name}";
    return str;
  }

  public override double ComputeEndTime()
  {
    return this.StartTime + this.ActiveDuration + this.InactiveDuration;
  }

  public override string InactiveDurationToString() => this.InactiveDuration.ToString();

  public override string PriorityToString() => this.Priority.ToString();
}
